"""
2017.05.31
"""

try:
    data = open('missing.txt')
    print(data.readline(), end='')
except IOError as err:
    # print('File error: ' + err)  # TypeError: Can't convert 'FileNotFoundError' object to str implicitly
    print('File error: ' + str(err))
finally:
    if 'data' in locals():
        data.close()

# 使用with处理文件，就不需要使用finally
try:
    with open('missing.txt') as data:
        print(data.readline(), end='')
except IOError as err:
    print('File error: ' + str(err))
